#include "utility.h"
#include "math.h"
double RootMeanSquareCal16(int16_t *nums, uint16_t count){
    uint64_t sum = 0;
    for(uint16_t i = 0; i < count; i++){
        sum += nums[i] * nums[i];
    }
    return count ? sqrt(sum / count) : 0.0f;
}


void printText(const char *str, uint32_t color)
{
    switch (color) {
        case RED:
            printf("\033[0;31m");
            break;
        case BLUE:
            printf("\033[0;34m");
            break;
        case WHITE:
            printf("\033[0;37m");
            break;
    }
    printf(str);
}

void printNum(uint8_t num, uint32_t color)
{
    static uint8_t cnt = 0;
    switch (color) {
        case RED:
            printf("\033[0;31m");
            break;
        case BLUE:
            printf("\033[0;34m");
            break;
        case WHITE:
            printf("\033[0;37m");
            break;
    }
    printf(" %d ", num);
    cnt++;
    if (cnt == 16) {
        printf("\r\n");
        cnt = 0;
    }
}
